
<?php
$model = new ClassCourseQuery;
$form = $this->beginWidget('GxActiveForm', array(
    'id' => 'class-course-query-form',
    'action' => $this->createUrl('ClassCourseQuery/Create'),
    'enableAjaxValidation' => true,
        ));
?>
<div class="padding20px" id="class-course-query-form-Show">
    <div class="formElements">
        <div class="col-2">
            <?php echo $form->errorSummary($model); ?>
            <?php if ($class_course_type == 'classes') { ?>
                <?php echo $form->hiddenField($model, 'classes_id', array('maxlength' => 45, 'class' => 'field', 'placeholder' => 'Enter Name', 'value' => $classId)); ?>
            <?php } else { ?>
                <?php echo $form->hiddenField($model, 'courses_id', array('maxlength' => 45, 'class' => 'field', 'placeholder' => 'Enter Name', 'value' => $classId)); ?>
            <?php } ?>

            <div class="common">
                <div class="col col1">
                    <?php echo $form->textField($model, 'queryuser_name', array('maxlength' => 45, 'class' => 'field', 'placeholder' => 'Enter Name')); ?>
                    <?php echo $form->error($model, 'queryuser_name'); ?>
                </div>
                <div class="col col2">
                    <?php echo $form->textField($model, 'queryuser_email', array('maxlength' => 45, 'class' => 'field', 'placeholder' => 'Enter Email')); ?>
                    <?php echo $form->error($model, 'queryuser_email'); ?>

                </div>
                <div class="clear"></div>
            </div>
            <div class="common">
                <?php echo $form->textArea($model, 'query_message', array('placeholder' => 'Write Query')); ?>
                <?php echo $form->error($model, 'query_message'); ?>
            </div>                                                               	
        </div>

        <?php
        echo CHtml::ajaxSubmitButton('Submit', CHtml::normalizeUrl(array('classCourseQuery/create')), array(
            'dataType' => 'json',
            'type' => 'post',
            'success' => 'function(data) {
                         $("#AjaxLoader").hide();  
                        if(data.status=="success"){
                        $("#class-course-query-form-formResult").show();
                         $("#class-course-query-form-formResult").html("Your Query submitted successfully.");
                         $("#class-course-query-form-Show").hide();                        
                        }
                         else{
                        $.each(data, function(key, val) {                       
                        $("#class-course-query-form #"+key+"_em_").text(val);                                                    
                        $("#class-course-query-form #"+key+"_em_").show();
                        $("#class-course-query-form .common").css("margin-bottom","0px");
                        });
                        }       
                    }',
            'beforeSend' => 'function(){                        
                           $("#AjaxLoader").show();
                      }'
                ), array('id' => 'mybtn', 'class' => 'btn '));
        ?>
         <div id="AjaxLoader" style="margin: 0 auto;width: 50%;display: none;"><img src="<?php echo ThemePath(); ?>/images/AjaxLoader.gif"></img></div>
        <div class="clear"></div>
    </div>
</div>
<?php $this->endWidget(); ?>

